package com.hjqjl.whdemo.workmanager;

import android.content.Context;
import android.os.Handler;

import androidx.annotation.NonNull;
import androidx.work.Worker;
import androidx.work.WorkerParameters;

import com.blankj.utilcode.util.AppUtils;
import com.blankj.utilcode.util.LogUtils;
import com.hjqjl.whdemo.db.room.database.AppDatabase;
import com.hjqjl.whdemo.db.room.dao.AnimeDao;

/**
 * @date :2021/4/30 16:27 wh
 */
public class MyWorker extends Worker {
    private AnimeDao animeDao = AppDatabase.getInstance().animeDao();
    public MyWorker(
            @NonNull Context context,
            @NonNull WorkerParameters params) {
        super(context, params);
    }

    @Override
    public Result doWork() {
        LogUtils.v("workManager开始啦");
//        HttpMethods.getInstance().getJoke("1")
//                .subscribeOn(Schedulers.io())
//                .observeOn(Schedulers.io())
//                .subscribe(new BaseObserver<GetJoke>() {
//                    @Override
//                    public void onSuccess(GetJoke getJoke) {
//                        LogUtils.v("workManager联网" + new Random().nextInt(100) + "==>" + getJoke.toString());
//                    }
//                });

//        animeDao.insertOneAnime(createOneAnime());
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        LogUtils.v("workManager结束啦");
        return Result.success();
    }

//    private Anime createOneAnime() {
//        Anime anime = new Anime();
//        anime.setName("青春猪头少年不会梦到兔女郎学姐ww" + new Random().nextInt(100));
//        anime.setType("奇幻&恋爱wwww");
//        anime.setPlayDate("2018-10www");
//        anime.setEpisode(131);
//        return anime;
//    }
}
